{$CLEO .qa}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "BCHTRN"

// By ArtemQa146

const
    Chef_1 = 31@
    Ped_ID = 29@
    coords_x = 28@
    coords_y = 27@
    coords_z = 26@
    angle_1 = 25@
end



                0087: coords_x = 0@ // (float)
                0087: coords_y = 1@ // (float)
                0087: coords_z = 2@ // (float)
                0087: angle_1 = 3@ // (float)
                
                if
                    0E4D: random_percent 50
                then
                else
                    repeat
                    wait 0
                    until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos coords_x coords_y coords_z radius 100.0
                    0A93: terminate_this_custom_script
                end


                repeat
                wait 0
                04ED: load_animation  "PedEventsMod"
                until 04EE:   animation "PedEventsMod" loaded

                if 0E4D: random_percent 50
                then Ped_ID = 96
                else Ped_ID = 90
                end

                model.Load(Ped_ID)
                if
                    not model.Available(Ped_ID)
                then
                    repeat
                    wait 0
                    model.Load(Ped_ID)
                    until model.Available(Ped_ID)
                end
                038B: load_requested_models

                009A: Chef_1 = create_actor_pedtype 4 model Ped_ID at coords_x coords_y coords_z
                0173: set_actor Chef_1 Z_angle_to angle_1

                0812: AS_actor Chef_1 perform_animation "Bch_tran" IFP "PedEventsMod" framedelta 1000.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB
                0E24: fix_char Chef_1 ground 1 brightness 1 and_fade_in 0

                model.Destroy(Ped_ID)

                repeat
                wait 0
                if
                    056D:   actor Chef_1 defined
                then

                    0E40: get_current_hour 1@
                    0D59: get_current_weather_to 2@
                    if or
                        2@ == 8
                        2@ == 16
                        1@ >= 14
                    then
                        break
                    end

                    080E: get_actor Chef_1 ped_event_to 1@
                    if or
                        1@ == 49
                        1@ == 9
                        1@ == 15
                        1@ == 31
                        1@ == 59
                    then
                        break
                    end

                    if or
                        0118:   actor Chef_1 dead
                        not locate_char_distance_to_char $player_actor char Chef_1 radius 120.0
                        not $ACTIVE_INTERIOR == 0
                        051A:   actor Chef_1 damaged_by_actor $PLAYER_ACTOR
                        not is_char_script_controlled Chef_1
                    then
                        break
                    end

                    if
                        0457:   player $PLAYER_CHAR aiming_at_actor Chef_1
                    then
                        0E83: get_current_char_weaponinfo $PLAYER_ACTOR store_to 1@
                        0E89: get_weaponinfo_fire_type 1@ store_to 2@ //     
                        if or
                            2@ == 1 //  
                            2@ == 3 //   (  ..)
                        then
                            break
                        end
                    end

                end
                until not player.Defined(0)

                if 056D:   actor Chef_1 defined
                then 01C2: remove_references_to_actor Chef_1 // Like turning an actor into a random pedestrian
                end
                04EF: release_animation "PedEventsMod"

                repeat
                wait 0
                until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos coords_x coords_y coords_z radius 120.0

0A93: terminate_this_custom_script
